/*
 * JavaZOOM : jlgui@javazoom.net http://www.javazoom.net
 * ----------------------------------------------------------------------- This
 * program is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Library General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option) any
 * later version. This program is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
 * General Public License for more details. You should have received a copy of
 * the GNU Library General Public License along with this program; if not, write
 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
 * USA.----------------------------------------------------------------------
 */
package de.preamp.clients.java.player;

import java.util.Collection;

/**
 * This class implements a threaded events launcher. It is based on
 * javazoom.jlgui.basicplayer.BasicPlayerEventLauncher
 * 
 * @author André Stannek
 * @since 2010-08-18
 * @version 2010-08-18
 */
public class PreampPlayerEventLauncher extends Thread
{
    /**
     * 
     */
    private final transient EventType code;

    /**
     * 
     */
    private final transient int position;

    /**
     * 
     */
    private final transient double value;

    /**
     * 
     */
    private final transient Object description;

    /**
     * 
     */
    private final transient Collection<PreampPlayerListener> listeners;

    /**
     * 
     */
    private final transient Object source;

    /**
     * Constructor.
     * 
     * @param code
     *            type of the event
     * @param position
     *            the position
     * @param value
     *            the value
     * @param description
     *            the description
     * @param listeners
     *            the listeners to notify
     * @param source
     *            the source of the event
     */
    public PreampPlayerEventLauncher(final EventType code, final int position,
	    final double value, final Object description,
	    final Collection<PreampPlayerListener> listeners,
	    final Object source)
    {
	super();
	this.code = code;
	this.position = position;
	this.value = value;
	this.description = description;
	this.listeners = listeners;
	this.source = source;
    }

    @Override
    public final void run()
    {
	if (listeners != null)
	{
	    for (final PreampPlayerListener listener : listeners)
	    {
		listener.stateUpdated(new PreampPlayerEvent(source, code,
			position, value, description));
	    }
	}
    }
}
